#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int maxProfit(vector<int> &prices)
    {
        vector<vector<int>> v(prices.size() + 1, {0, 0});
        v[0][1] = -prices[0];
        for (int i = 1; i <= prices.size(); ++i)
        {
            v[i][0] = max(v[i - 1][0], v[i - 1][1] + prices[i]);
            v[i][1] = max(v[i - 1][1], v[i - 1][0] - prices[i]);
        }
        return v[prices.size()][0];
    }
};

int main()
{
    Solution a;
    vector<int> tmp = {1};
    a.maxProfit(tmp);
    return 0;
}